package com.wondedDream.controller.admin;

import com.wondedDream.model.User;
import com.wondedDream.service.UserService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController(value = "adminUserController")
@RequestMapping("/api/users")
@Api(description = "管理端-用户信息")
public class UserController {

    @Autowired
    private UserService userService;

    // 注册新用户
    @PostMapping("/register")
    @ApiOperation(value = "注册新用户")
    public User registerUser(@RequestBody User user) {
        return userService.saveUser(user);
    }

    // 获取用户信息
    @GetMapping("/{id}")
    @ApiOperation(value = "获取用户信息")
    public User getUserById(@PathVariable Integer id) {
        return userService.getUserById(id);
    }

    // 获取所有用户信息
    @GetMapping("/")
    @ApiOperation(value = "获取所有用户信息")
    public List<User> getAllUsers() {
        return userService.getAllUsers();
    }
}